package com.design_pattern._02_structure._04_proxy;

import java.util.Date;

/**
 * 静态代理，用组合，代替V2的继承，这里更灵活，可以在后面实现多层代理，用继承无法实现多代理
 */
public class V3 {
    public static void main(String[] args) {
        Movable move = new Tank();
        Movable proxy = new TankProxy(move); // 都继承自Movable，所以可以互相调用
        proxy.move();
    }
}

class TankProxy implements Movable{
    private Movable move;
    public TankProxy(Movable move){
        this.move = move; // 这里也可以直接new出来Tank
    }
    @Override
    public void move() {
        System.out.println("start in " + new Date().getTime());
        move.move();
        System.out.println("stop in " + new Date().getTime());
    }
}

